<template>
  <d2-container>
    <el-form ref="form" :model="form" label-width="130px">
      <el-col :span="24">
        <h3>基本信息</h3>
      </el-col>
      <el-col :span="12">
        <el-form-item label="单位名称">
          <el-input v-model="form.companyName" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="单位名称（英文）">
          <el-input v-model="form.companyNameEn" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="地址">
          <el-input v-model="form.address" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="地址（英文）">
          <el-input v-model="form.addressEn" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
      <el-form-item label="证书单位名称">
        <el-input v-model="form.certificateCompanyName" size="mini"></el-input>
      </el-form-item>
      </el-col>
      <el-col :span="12">
      <el-form-item label="证书单位地址">
        <el-input v-model="form.certificateCompanyAddr" size="mini"></el-input>
      </el-form-item>
      </el-col>
      <el-col :span="24">
      <el-form-item label="现场检测地址">
        <el-input v-model="form.sceneTestingAddress" size="mini"></el-input>
      </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="客户联系人">
          <el-input v-model="form.contacter" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="手机号码">
          <el-input v-model="form.telephone" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="客户对接部门">
          <el-input v-model="form.companyDepart" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="客户负责人">
          <el-input v-model="form.companyCharge" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="单位类别">
          <el-select v-model="form.companyType" placeholder="" size="mini">
            <el-option key="'companyType' + 1" label="第一类别" value="1"></el-option>
            <el-option key="'companyType' + 2" label="第二类别" value="2"></el-option>
            <el-option key="'companyType' + 3" label="第三类别" value="3"></el-option>
            <el-option key="'companyType' + 4" label="第四类别" value="4"></el-option>
            <el-option key="'companyType' + 5" label="第五类别" value="5"></el-option>
            <el-option key="'companyType' + 6" label="第六类别" value="6"></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="统一社会信用代码">
          <el-input v-model="form.creditCode" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="业务组">
          <el-input v-model="form.groupId" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="业务员">
          <el-input v-model="form.groupUserId" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="固定电话">
          <el-input v-model="form.mobilePhone" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="传真">
          <el-input v-model="form.fax" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="邮箱">
          <el-input v-model="form.email" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="邮编">
          <el-input v-model="form.postCode" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="所属行业">
          <el-select v-model="form.companyBusinessType" placeholder="" size="mini">
            <el-option key="'companyBusinessType' + 1" label="食品安全计量" value="1"></el-option>
            <el-option key="'companyBusinessType' + 2" label="医学计量" value="2"></el-option>
            <el-option key="'companyBusinessType' + 3" label="炼化企业" value="3"></el-option>
            <el-option key="'companyBusinessType' + 4" label="销售企业" value="4"></el-option>
            <el-option key="'companyBusinessType' + 5" label="中海油企业" value="5"></el-option>
            <el-option key="'companyBusinessType' + 6" label="中石化企业" value="6"></el-option>
            <el-option key="'companyBusinessType' + 7" label="油田企业" value="7"></el-option>
            <el-option key="'companyBusinessType' + 8" label="管道企业" value="8"></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="18">
        <el-form-item label="行政区划">
          <el-select v-model="form.provinceId" placeholder="" size="mini">
            <el-option key="'provinceId' + 1" label="启用" value="1"></el-option>
            <el-option key="'provinceId' + 0" label="禁用" value="2"></el-option>
          </el-select>
          <el-select v-model="form.cityId" placeholder="" size="mini">
            <el-option key="'cityId' + 1" label="启用" value="1"></el-option>
            <el-option key="'cityId' + 0" label="禁用" value="2"></el-option>
          </el-select>
          <el-select v-model="form.areaId" placeholder="" size="mini">
            <el-option key="'areaId' + 1" label="启用" value="1"></el-option>
            <el-option key="'areaId' + 0" label="禁用" value="2"></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="12">
      <el-form-item label="证书要求">
        <el-input v-model="form.certificateRequirement" size="mini"></el-input>
      </el-form-item>
      </el-col>
      <el-col :span="12">
      <el-form-item label="上门特殊要求">
        <el-input v-model="form.visitSpecialRequirement" size="mini"></el-input>
      </el-form-item>
      </el-col>
      <el-col :span="12">
      <el-form-item label="其他特殊要求">
        <el-input v-model="form.otherSpecialRequirement" size="mini"></el-input>
      </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="业务提成">
          <el-input v-model="form.businessPromotion" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="报告材质">
          <el-select v-model="form.reportType" placeholder="" size="mini">
            <el-option key="'reportType' + 1" label="纸质" value="1"></el-option>
            <el-option key="'reportType' + 2" label="电子" value="2"></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="12">
      <el-form-item label="备注">
        <el-input v-model="form.remark" size="mini"></el-input>
      </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="质量体系认证">
          <el-select v-model="form.qualitySystem" placeholder="" size="mini">
            <el-option key="'qualitySystem' + 1" label="通过" value="1"></el-option>
            <el-option key="'qualitySystem' + 0" label="未通过" value="0"></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="证书编号">
          <el-input v-model="form.certificateNum" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="企业规模">
          <el-select v-model="form.companyScale" placeholder="" size="mini">
            <el-option key="'companyScale' + 1" label="小" value="1"></el-option>
            <el-option key="'companyScale' + 2" label="中" value="2"></el-option>
            <el-option key="'companyScale' + 3" label="大" value="3"></el-option>
            <el-option key="'companyScale' + 4" label="特大" value="4"></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="人数">
          <el-input v-model="form.totalPerson" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="产值">
          <el-input v-model="form.outputValue" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="销售量">
          <el-input v-model="form.outputNum" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="销售额">
          <el-input v-model="form.salesVolume" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="经济类型">
          <el-select v-model="form.economicType" placeholder="" size="mini">
            <el-option key="'economicType' + 1" label="国有" value="1"></el-option>
            <el-option key="'economicType' + 2" label="有限责任公司" value="2"></el-option>
            <el-option key="'economicType' + 3" label="集体" value="3"></el-option>
            <el-option key="'economicType' + 4" label="股份有限公司" value="4"></el-option>
            <el-option key="'economicType' + 5" label="股份合作" value="5"></el-option>
            <el-option key="'economicType' + 6" label="私营" value="6"></el-option>
            <el-option key="'economicType' + 7" label="联营" value="7"></el-option>
            <el-option key="'economicType' + 8" label="其他企业" value="8"></el-option>
            <el-option key="'economicType' + 9" label="合资经营" value="9"></el-option>
            <el-option key="'economicType' + 10" label="合作经营" value="10"></el-option>
            <el-option key="'economicType' + 11" label="港澳台独资经营" value="11"></el-option>
            <el-option key="'economicType' + 12" label="港澳台投资股份有限公司" value="12"></el-option>
            <el-option key="'economicType' + 13" label="中外合资" value="13"></el-option>
            <el-option key="'economicType' + 14" label="中外合作" value="14"></el-option>
            <el-option key="'economicType' + 15" label="外资企业" value="15"></el-option>
            <el-option key="'economicType' + 16" label="外商投资股份有限公司" value="16"></el-option>
            <el-option key="'economicType' + 17" label="个体户" value="17"></el-option>
            <el-option key="'economicType' + 18" label="个人合作" value="18"></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="许可证编号">
          <el-input v-model="form.licenceNum" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="许可范围">
          <el-input v-model="form.licenceRange" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="有效日期">
          <el-input v-model="form.licenceDate" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <h3>开票信息</h3>
      </el-col>
      <el-col :span="12">
        <el-form-item label="名称">
          <el-input v-model="form.invoiceCompany" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="纳税人识别号">
          <el-input v-model="form.taxNo" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="地址、电话">
          <el-input v-model="form.invoiceAddressTel" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="开户行、账号">
          <el-input v-model="form.accountBankNo" size="mini"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="24">
      <el-form-item>
        <el-button type="primary" @click="handleSubmit">立即创建</el-button>
        <el-button>取消</el-button>
      </el-form-item>
      </el-col>
    </el-form>
  </d2-container>
</template>

<script>
import api from '@/api'

export default {
  name: 'market-customer-create',
  created () {
    this.getDepartmentList()
    this.getProvinceList()
  },
  methods: {
    async getProvinceList () {
      var res = await api.COMMON_REGION_LIST({
        id: 0,
        parentId: 0
      })
      console.log(res.list)
    },
    async getDepartmentList () {
      var res = await api.OA_DEPARTMEN_LIST({
        pageNo: 1,
        pageSize: 100
      })
      this.departmentList = res.list
    },
    handleSubmit () {
      if (this.form.id) {
        api.MARKET_CUSTOMER_EDIT(this.form)
      } else {
        delete this.form.id
        api.MARKET_CUSTOMER_CREATE(this.form)
      }
    },
    initForm () {
    }
  },
  data () {
    return {
      departmentList: [],
      provinceList: [],
      cityList: [],
      countyList: [],
      form: {
        id: 0,
        companyName: '',
        companyNameEn: '',
        address: '',
        addressEn: '',
        certificateCompanyName: '',
        certificateCompanyAddr: '',
        sceneTestingAddress: '',
        contacter: '',
        telephone: '',
        companyDepart: '',
        companyCharge: '',
        companyType: '1',
        creditCode: '',
        groupId: '',
        groupUserId: '',
        mobilePhone: '',
        fax: '',
        email: '',
        postCode: '',
        companyBusinessType: '1',
        provinceId: '',
        cityId: '',
        areaId: '',
        certificateRequirement: '',
        visitSpecialRequirement: '',
        otherSpecialRequirement: '',
        businessPromotion: 0,
        reportType: '1',
        remark: '',
        qualitySystem: '1',
        certificateNum: '',
        companyScale: '1',
        totalPerson: '',
        outputValue: '',
        outputNum: '',
        salesVolume: '',
        economicType: '1',
        licenceNum: '',
        licenceRange: '',
        licenceDate: '',
        invoiceCompany: '',
        taxNo: '',
        invoiceAddressTel: '',
        accountBankNo: ''
      }
    }
  }
}
</script>
